



var presentation = cc.Layer.extend({
   
   _TextBox:null,
	
    init:function () {
        var selfPointer = this;
        //////////////////////////////
        // 1. super init first
        this._super();

		this.setTouchEnabled(true);
		this.setKeyboardEnabled(true);
		
		
        var size = cc.Director.getInstance().getWinSize();

        // add "HelloWorld" splash screen"
        var background = cc.Sprite.create("res/LightedBackground.png");
        background.setPosition(cc.p(size.width / 2, size.height / 2));
        background.setVisible(true);
        background.setAnchorPoint(cc.p(0.5, 0.5));
        this.addChild(background, 0);

		// avatar
		var avatar = cc.Sprite.create("res/avatar_body.png");
		avatar.setPosition(cc.p(size.width - 150, size.height / 2 - 150 ));
		avatar.setAnchorPoint(cc.p(0.5, 0));
		background.addChild(avatar, 0);
		

		// TextBox
		
		var tmp = Textbox_Style1.create();
		tmp.setPosition(cc.p(200, 200));
		background.addChild(tmp);

		/*
		tmp.TextToDisplay = [
							"Hi, I'm Marius Ibanez,",
							"a French video game developer really",
							"passionate about my job.",
							
							"I like to work on challenging and interesting",
							"games. Giving my best to satisfy the final",
							"player and deliver games than I'm proud of.",

							"I'm curious about every part Programming",
							"Domain, even if my preference goes to AI,",
							"Gameplay and Interfaces.",
							
							"During my free time, I work on little",
							"projects in many different platforms,",
							"to learn and try new programming technics",
							
							"or research that I read about.",
							"I like also to travel, meet new people,",
							"share experience.",
							
							];
		*/
		
		var str =   "\
Hi, I'm Marius Ibanez, \
a French video game developer really \
passionate about my job. \
I like to work on challenging and interesting \
games. Giving my best to satisfy the final \
player and deliver games than I'm proud of. \
I'm curious about every part Programming \
Domain, even if my preference goes to AI, \
Gameplay and Interfaces. \
During my free time, I work on little \
projects in many different platforms, \
to learn and try new programming technics \
or research that I read about. \
I like also to travel, meet new people, \
share experience.\
";
		
		tmp.setTextToShow( str );
		
		this._TextBox = tmp;
		
		
		
		
		//Menu
		var items = new Array();
		var p = cc.p( (-size.width/2) + 20 ,
					  (-size.height/2) + 30 );
		
		items[0] = createButton("Back");
		items[0].setPosition( p );
		
		items[0].setCallback(this,
            function () {
				myApp.GoToScene( new HelloWorldScene() );
            });
		

		var myMenu = cc.MenuCustom.create(items);
		this.addChild(myMenu);
		
		
		
		
        return true;
    },
	
	onTouchesEnded:function (pTouch,pEvent){
        //this._TextBox.handleTouch(pTouch[0].getLocation());
    },
    onTouchesMoved:function(pTouch,pEvent){
        //this._TextBox.handleTouchMove(pTouch[0].getLocation());
    },
    onKeyUp:function(e){
		this._TextBox.handleKeyUp(e);
    },
    onKeyDown:function(e){
        this._TextBox.handleKeyDown(e);
    },
});


var presentationScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new presentation();
        layer.init();
        this.addChild(layer);
    }
});


